package utils

import (
	"smartposts/internal/models"
	"time"
	"math"
)

func CompositeScore(post models.Post) float64 {
	const alpha = 1.5
	const c = 2.0 // 避免时间为0

	// 时间衰减：单位小时
	hours := time.Since(post.CreatedAt).Hours()

	// 分数计算
	score := float64(post.VoteCount) / math.Pow(hours+c, alpha)
	return score
}